
#ifndef CONTAINER_SERVICE_AGENT_IMPL_H_
#define CONTAINER_SERVICE_AGENT_IMPL_H_

#include "common/module-logger.h"
#include "interface/logger.h"
#include "service/interface/service-agent.h"
#include <string>

namespace fasmio { namespace container {

class ServiceAgentImpl : public service::IServiceAgent
{
public:
    explicit ServiceAgentImpl(ILogger* logger, const char* name);
    virtual ~ServiceAgentImpl();

public:
    bool Attach(service::IService *service);
    service::IService* Detach();

    bool Initialize();
    void Finalize();

public:
    virtual service::ServiceState GetServiceState();

public:
    virtual bool RegisterPushSlot   (const char* name, service::TaskAllocator alloc, service::PushSlotHandler handler, unsigned concurrency);
    virtual bool RegisterPopSlot    (const char* name, service::IOutQueue **queue);
    virtual bool RegisterQuerySlot  (const char* name, service::QuerySlotHandler handler);
    virtual bool RegisterUpdateSlot (const char* name, service::TaskAllocator alloc, service::UpdateSlotHandler handler);
    virtual bool RegisterDeleteSlot (const char* name, service::DeleteSlotHandler handler);

public:
    virtual bool ServiceConfiguring ();
    virtual bool ServiceConfigured  ();
    virtual bool ServiceError       ();

public:
    virtual unsigned long GetInQueueSize         ();
    virtual unsigned long GetInQueueDoingCount   ();
    virtual unsigned long GetInQueueTraffic      ();
    virtual unsigned long GetOutQueueSize        ();
    virtual unsigned long GetOutQueueDoingCount  ();
    virtual unsigned long GetOutQueueTraffic     ();

private:
    ILogger* logger_;
    std::string name_;
    common::ModuleLogger mlogger_;

    service::IService      *service_;
    service::ServiceState   state_;
};

}}  // namespace fasmio::container

#endif  // CONTAINER_SERVICE_AGENT_IMPL_H_

